$(function () {
    getThreeRoom();
    getNews();
});

function getThreeRoom() {
    let result = myAjax('/getThreeRoom', 'get', {});
    let html = "";
    let data = result.list;
    for (let i = 0; i < data.length; i++) {
        html += ' <div>\n' +
            '     <div class="photo" onclick="jumpDetails()"><img src="'+data[i].room+'"/></div>\n' +
            '     <div>\n' +
            '     <img src="'+data[i].back+'"/>\n' +
            '     <div class="textone">\n' +
            '    '+data[i].title+'\n' +
            '                        </div>\n' +
            '                        <div class="texttwo">\n' +
            '                            <div onclick="jumpDetails()"> ></div>\n' +
            '                            <div onclick="jumpDetails()"> MORE DETAILS</div>\n' +
            '                        </div>\n' +
            '                    </div>\n' +
            '                </div>';
    }
    $("#roomShow").html(html)
}
function jumpDetails() {
   window.open("/html/service.html")
}

function getNews() {
    let result = myAjax('/getNews', 'get', {});
    let html ="";
    let data = result.list;
    for (let i= 0;i<data.length;i++){
        html+='<div>\n' +
            '  <div onclick="jumpPage('+data[i].id+')">'+data[i].newsTitle+'</div>\n' +
            '  <div>'+data[i].releaseTime+'</div>\n' +
            '  </div>';
    }
    $("#news").html(html);
}
function jumpPage(id) {
 localStorage.setItem("newsId",id);
 window.open("/html/newsDetails.html");
}